JavaScript array if one element same takes another element in array

visit shbcf.ru